package com.tfswue.dyq.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tfswue.dyq.entity.User;
import com.tfswue.dyq.mapper.UserMapper;
import com.tfswue.dyq.service.Userservice;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class UserController {
    @Autowired
    private Userservice userservice;
    @Autowired
    private UserMapper userMapper;

    @RequestMapping("/getUser")
    public String getUser() {
        //queryWrapper条件构造器，list（）===select * from user where id=? and username = ?
        //queryWrapper.eq("id",1).eq("username","theonefx");
        //select * from user where id=? and username = theonefx
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("id",1);
        queryWrapper.eq("username","theonefx");
        List<User> list = userservice.list(queryWrapper);
        return String.valueOf(userservice.getById(1));
    }
}
